** Replication Code for:
** Terrorism Activates Ethnocentrism to Explain Greater Willingness to 
** Sacrifice Civil Liberties: Evidence from Germany
** Authors: Christina Novak Hansen and Peter Thisted Dinesen 
** Date: 10/02/2021

*-------------------------------------------------------------------------------


*-------------------------------------------------------------------------------
*2. Data preparation
*-------------------------------------------------------------------------------


clear
use Hansen&Dinesen_Replication_Data_GGSS2016-subset.dta, clear		
recode za_nr (5250=2016), gen(year)
gen edate=mdy(xt02,xt01,year)
format edate %tdDD/NN/CCYY
bysort edate: gen Interviews=_N if respid!=.


********************************Demographic Variables***************************
		
*Age
codebook age, tab (100)
recode age (-32=.)
gen st_age = ((age-18)/79)
tab2 age st_age
codebook st_age, tab(100)

*Age squared 
gen age2 = age*age
gen st_age2 = st_age*st_age
codebook st_age2, tab(100)

*Citizenship					
/*Notice that GGSS differantiates between those with only a German citizenship,
with both a German and another citizenship, and those with a foreign citizenship. 
Moreover, GGSS includes information on the citizensip of the respondents 
parents and grandparents. Therefore, we create a variable differante between 
this below.*/
codebook german
rename german ctzn
recode ctzn (-32=.) (3=0 "Not German citizen") (1 2=1 "German citizen"), gen(german)
recode fdm01a (-33 -9 -8=.), gen(ctzndad)
recode mdm01a (-33 -9 -8=.), gen(ctznmum)

*Education variable based on ISCED2011
codebook isced11, tab(100)
recode isced11 (-32=.)
recode isced11 (7 8 = 7), gen(proedu)
codebook proedu
label variable proedu "Highest level of education, ISCED-2011"
label values proedu isced11
/*Notice that the category 7 not only includes master-level but also
doctoral level respondents.*/

*Less detailed version
gen proedu2=.
replace proedu2=1 if inlist(proedu, 1,2)
replace proedu2=2 if proedu==3
replace proedu2=3 if inlist(proedu, 4, 5)
replace proedu2=4 if proedu==6 | proedu==7
label variable proedu2 "Highest level of education"
label define proedu2LB 1 "Lower secondary or less" 2 "Upper secondary" ///
		3 "Short tertiary education" 4 "Medium to long tertiary education" 
label values proedu2 proedu2LB
gen st_proedu2 = ((proedu2-1)/3)
tab2 proedu2 st_proedu

gen low_second = 0 if proedu2!=.
replace low_second = 1 if proedu2==1
tab proedu2 low_second
gen upp_second = 0 if proedu2!=.
replace upp_second = 1 if proedu2==2
tab proedu2 upp_second
gen short_tert = 0 if proedu2!=.
replace short_tert = 1 if proedu2==3
tab proedu2 short_tert
gen medlong_tert = 0 if proedu2!=.
replace medlong_tert = 1 if proedu2==4
tab proedu2 medlong_tert


*Sex
rename sex gndr
recode gndr (1=0 "Male") (2=1 "Female"), gen(sex)
codebook gndr sex

*Working status, detailled
codebook work dw03, tab(100)
rename work arbeit
gen work1 = 1 if arbeit==1 /*full-time work*/
replace work1 = 2 if arbeit==2 /*part time work*/
replace work1 = 3 if (arbeit==3 | arbeit==4) & dw03==2 /*pensionist*/
replace work1 = 4 if (arbeit==3 | arbeit==4) & (dw03==3 | dw03==6) /*Unemployed or not in workforce*/
replace work1 = 5 if (arbeit==3 | arbeit==4) & dw03==1 /*Student/in school*/
replace work1 = 6 if (arbeit==3 | arbeit==4) & dw03==4 /*Housework*/
label variable work1 "Working status, detailed"
label define work1LB 1 "Full-time work" 2 "Part-time work" 3 "Retired" ///
	4 "Unemployed or not in workforce" 5 "In school or student" ///
	6 "Housework"
label values work1 work1LB
codebook work dw03 work1, tab(100)

*Working status, general
recode work1 (1 2 =2) (4 = 1) (3 = 3) (6 = 4) (5 = 5), gen(work2)
label variable work2 "Working status"
label define work2LB  1 "Unemployed" 2 "Working" 3 "Retired" ///
	4 "Housework" 5 "In school or student"
label values work2 work2LB
gen st_work2 = ((work2-1)/4)
codebook work2 st_work2
tab2 work2 st_work2

*Work dummies for balance tests
recode work2 (2=1) (1 3 4 5=0), gen(working)
recode work2 (1=1) (2 3 4 5=0), gen(unemployed)
recode work2 (3=1) (1 2 4 5=0), gen(retired)
recode work2 (4=1) (1 2 3 5=0), gen(housework)
recode work2 (5=1) (1 2 3 4=0), gen(student)

*-------------------------------------------------------------------------------


/* All independent and dependent variables were recoded so that higher values 
reflect more negative/hostile opinions towards the outgroup OR more 
fearful opinions when it comes to civil liberties. */



***************************Independent variables********************************

							****Ethnocentrism***

*A society with high levels of cultural diversity will be better at tackling new problems.
recode ma13 (-9 -8=-99 "Missing") (1=1 "Completely agree") ///
	(4=4 "Completely disagree"), gen(diversity_mi)
recode ma13 (-9 -8=.) (1=1 "Completely agree") ///
	(4=4 "Completely disagree"), gen(diversity)
recode ma13 (1=1) (2=3) (3=5) (4=7) (-9 -8=.), gen(diversity_rscale)
label variable diversity "A society with high levels of cultural diversity will be better at tackling new problems."	
codebook ma13 diversity 
gen st_diversity = ((diversity-1)/3)
tab diversity st_diversity

/*Do you think that the presence of foreigners is advantageous or disadvantageous for
Germany?*/
recode ma11 (-8 -9=-99 "Missing") (1=1 "Clearly advantageous") (2=2 "Rather advantageous") ///
(3=3 "Neither one nor the other") (4=4 "Rather disadvantageous") ///
(5=5 "Clearly disadvantageous"), gen(foreign_advantage_mi)
recode ma11 (-8 -9=.) (1=1 "Clearly advantageous") (2=2 "Rather advantageous") ///
(3=3 "Neither one nor the other") (4=4 "Rather disadvantageous") ///
(5=5 "Clearly disadvantageous"), gen(foreign_advantage)
gen foreign_advantage_rscale=(((foreign_advantage-1)*6)/4)+1
gen st_foreign_advantage = ((foreign_advantage-1)/4)
tab foreign_advantage st_foreign_advantage

*It is better for a country, if all people belong to one common culture.
recode ma12 (1=4) (2=3) (3=2) (4=1) (-9 -8=-99 "Missing"), gen(homocult_mi)
recode ma12 (1=4) (2=3) (3=2) (4=1) (-9 -8=.), gen(homocult)
recode ma12 (1=7) (2=5) (3=3) (4=1) (-9 -8=.), gen(homocult_rscale)
label variable homocult "It is better for a country, if all people belong to one common culture"
label define homocultLB 1 "Completely disagree" 4 "Completely agree"
label values homocult homocultLB
gen st_homocult = ((homocult-1)/3)
tab homocult st_homocult

*The presence of foreigners in Germany leads to a loss of social cohesion.
recode mp09 (-9=-99 "Missing"), gen(imcoherence_mi)
recode mp09 (-9=.), gen(imcoherence)
gen imcoherence_mcar = 0 if imcoherence_mi!=.
replace imcoherence_mcar=1 if imcoherence_mi==-99
label variable imcoherence "The presence of foreigners in Germany leads to a loss of social cohesion."
label define likert7LB 1 "Completely disagree" 7 "Completely agree"
label values imcoherence likert7LB
tab mp09 imcoherence
gen st_imcoherence = ((imcoherence-1)/6)
tab imcoherence st_imcoherence

*Foreigners enrich the cultural life of Germany.
recode mp03 (-9=-99 "Missing") (1=7 "Completely disagree") (2=6) (3=5) (4=4) ///
	(5=3) (6=2) (7=1 "Completely agree"), gen(imenrich_mi)
recode mp03 (-9=.) (1=7 "Completely disagree") (2=6) (3=5) (4=4) ///
	(5=3) (6=2) (7=1 "Completely agree"), gen(imenrich)
label variable imenrich "Foreigners enrich the cultural life of Germany"
tab mp03 imenrich
gen st_imenrich = ((imenrich-1)/6)
tab imenrich st_imenrich

/*Foreigners living in Germany should choose to marry people of their own nationality.*/ 
codebook ma04
recode ma04 (-10=.) (-9 =-99 "Missing"), gen(immarry_mi)
recode ma04 (-9 -10=.), gen(immarry)
label variable immarry "Foreigners living in Germany should choose to marry people of their own nationality"
label values immarry likert7LB
gen st_immarry = ((immarry-1)/6)
tab immarry st_immarry

*Foreigners living in Germany should be prohibited from taking part in any kind of political activity in Germany.
/*The original value -10 termed 'Filter' entails those respondents who were not
asked the question because they were not German citizens.*/
recode ma03 (-10=.) (-9=-99 "Missing"), gen(imrights_mi)
recode ma03 (-10=.) (-9=.), gen(imrights)
label variable imrights "The foreigners living in Germany should be prohibited from taking part in any kind of political activity in Germany"
label values imrights likert7LB
tab ma03 imrights
gen st_imrights = ((imrights-1)/6)
tab imrights st_imrights

*Foreigners living in Germany should be entitled to the same welfare benefits and other social entitlements as Germans.
recode ma06 (-9=-99 "Missing") (1=7 "Completely disagree") (2=6) (3=5) (4=4) ///
	(5=3) (6=2) (7=1 "Completely agree"), gen(imsocial_mi)
recode ma06 (-9=.) (1=7 "Completely disagree") (2=6) (3=5) (4=4) ///
	(5=3) (6=2) (7=1 "Completely agree"), gen(imsocial)
label variable imsocial "Foreigners living in Germany should be entitled to the same welfare benefits and other social entitlements as Germans"
tab ma06 imsocial
gen st_imsocial = ((imsocial-1)/6)
tab imsocial st_imsocial

*With so many foreigners in Germany, one feels increasingly like a stranger in one’s own country.
recode ma09 (-10=.) (-9=-99 "Missing"), gen(stranger_mi)
recode ma09 (-10 -9=.), gen(stranger)
label variable stranger "With so many foreigners in Germany, one feels increasingly like a stranger in one’s own country"
label values stranger likert7LB
gen st_stranger = ((stranger-1)/6)
tab st_stranger stranger

*Foreigners living in Germany should adapt their way of life [a little] more closely to the German way of life.
/* This question figures in the split part of the survey. The sample was diveded
into two and almost the same questions were used in the two groups. The only 
difference in the question formulation was the wording "a little" - most
likely purpose was to measure social desirability bias.
*/
codebook ma01a ma01b, tab(100)
recode ma01a (-11 -10 -9=.), gen(split_a_WL)
gen st_split_a_WL = ((split_a_WL-1)/6)
tab split_a_WL st_split_a_WL
recode ma01b (-11 -10 -9=.), gen(split_b_WL)
gen st_split_b_WL = ((split_b_WL-1)/6)
tab split_b_WL st_split_b_WL

gen wlife_mi=.
replace wlife_mi=1 if (ma01a==1) | (ma01b==1)
replace wlife_mi=2 if (ma01a==2) | (ma01b==2)
replace wlife_mi=3 if (ma01a==3) | (ma01b==3)
replace wlife_mi=4 if (ma01a==4) | (ma01b==4)
replace wlife_mi=5 if (ma01a==5) | (ma01b==5)
replace wlife_mi=6 if (ma01a==6) | (ma01b==6)
replace wlife_mi=7 if (ma01a==7) | (ma01b==7)
replace wlife_mi=-99 if ma01a==-9 | ma01b==-9 
replace wlife_mi=. if ma01a==-10 | ma01b==-10
gen wlife = wlife_mi if wlife_mi!=-99
codebook wlife_mi 
tab wlife
label variable wlife "The foreigners living in Germany should try harder to adjust their life style to the German way of life"
label values wlife likert7LB
gen st_wlife = ((wlife-1)/6)
tab wlife st_wlife

gen splitvariable =.
replace splitvariable = 0 if split_a_WL!=.
replace splitvariable = 1 if split_b_WL!=.
label variable splitvariable "Whether the respondent was in split A or B for wlife"
label define splitvariableLB 0 "Split A (adapt a little more closely)" 1 "Split B (adapt more closely)"
label values splitvariable splitvariable LB
tab ma01a splitvariable
tab ma01b splitvariable


					***Construction of ethnocentrism index***

*Main ethnocentrism variables
gen ethno =(foreign_advantage_rscale + homocult_rscale + imrights + wlife ///
	+ immarry + stranger + imenrich + imcoherence + imsocial + diversity_rscale)/10
gen st_ethno =(st_foreign_advantage + st_homocult + st_imrights + st_wlife ///
	+ st_immarry + st_stranger + st_imenrich + st_imcoherence + ///
	st_imsocial + st_diversity)/10
codebook ethno st_ethno, tab(200)


*Categorical ethnocentrism variable
gen catethno=.
replace catethno=1 if ethno<2
replace catethno=2 if (ethno>=2 & ethno<3)
replace catethno=3 if (ethno>=3 & ethno<4)
replace catethno=4 if (ethno>=4 & ethno<5)
replace catethno=5 if (ethno>=5 & ethno<6)
replace catethno=6 if (ethno>=6 & ethno<7)
replace catethno=7 if ethno==7
codebook ethno catethno, tab(100)

*New dummy variables for ethnocentrism (standard-index)
tab ethno
di 100-66.48

*Upper 2/3 (66.81%) versus lower 1/3 of the observations (33.19%)
/* When counting frequencies the first 33,19 % percent consist 
of those respondents who take on a value on the
ethnocentrism index less than or equal to 2.75*/
gen ethno_upper2_3dummy = 0 if ethno!=.
replace ethno_upper2_3dummy = 1 if ethno>=2.8 & ethno!=.
tab ethno_upper2_3dummy
tab ethno ethno_upper2_3dummy

*Upper 1/3 (33.52%) versus lower 2/3 of the observations (66.48%)
/* When counting frequencies the first 66.48 % percent consist 
of those respondents who take on a value on the
ethnocentrism index less than or equal to 3.8*/
gen ethno_upper1_3dummy = 0 if ethno!=.
replace ethno_upper1_3dummy = 1 if ethno>3.8 & ethno!=.
codebook ethno_upper1_3dummy
tab ethno ethno_upper1_3dummy



				****Construciton of authoritarianism index***

*In general it will be of benefit for a child in later life if he or she is forced to conform to his or her parents’ ideas.
recode lp02 (-10=.) (-9=-99 "Missing")(1=1 "Completely disagree") ///
	(7=7 "Completely agree"), gen(authorchild_mi)
recode lp02 (-10 -9=.) (1=1 "Completely disagree") ///
	(7=7 "Completely agree"), gen(authorchild)
label variable authorchild "In general it will be of benefit for a child in later life if he or she is forced to conform to his or her parents’ ideas"
gen st_authorchild = ((authorchild-1)/6)
tab authorchild st_authorchild


						****Left-right ideology***

							
/*Many people use the terms ‘‘left’’ and ‘‘right’’ when they want to describe 
different political views. Here we have a scale which runs from left to right. 
Thinking of your own political views, where would you place these on this scale?*/
recode pa01 (-9=-99 "Missing") (1=1 "Left") (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (8=8) (9=9) (10=10 "Right"), gen(lrID_mi)
recode pa01 (-9=.) (1=1 "Left") (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (8=8) (9=9) (10=10 "Right"), gen(lrID)
label variable lrID "Left-right self-placement"
gen st_lrID = ((lrID-1)/9)
tab lrID st_lrID
codebook lrID, tab(100)

*-------------------------------------------------------------------------------


*-------------------------------------------------------------------------------




*******************************Dependent Variables******************************


/*Measurement of civil liberties was only conducted with half 
the sample (sample split). The category coded with 1 means that respondents 
received the civil liberties questions while respondents who received
other questions are coded as missing.*/

gen governmentsplit=.
replace governmentsplit=1 if J000==1
tab governmentsplit

				****Civil liberties (with reference to terrorism)***
/*Suppose the government suspected that a terrorist act was about to happen. 
Do you think the authorities should have the right to
...detain people for as long as they want without putting them on trial?*/
recode J014_1 (-13/-12=.) (-8 -9=-99 "Missing") (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(terror1_mi)
recode J014_1 (-13/-8=.) (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(terror1)
label variable terror1 "Terror prevention: Institutions can put people into unlimited detention"
gen st_terror1 = ((terror1-1)/3)
tab2 terror1 st_terror1

*... tap people’s telephone conversations?
recode J014_2 (-13/-12=.) (-8 -9=-99 "Missing") (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(terror2_mi)
recode J014_2 (-13/-8=.) (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(terror2)
label variable terror2 "Terror prevention: Institutions can intercept telephone calls"
codebook J014_2 terror2_mi
gen st_terror2 = ((terror2-1)/3)
tab2 terror2 st_terror2
		
*... stop and search people in the street at random?
recode J014_3 (-13/-12=.) (-8 -9=-99 "Missing") (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(terror3_mi)
recode J014_3 (-13/-8=.) (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(terror3)
label variable terror3 "Terror prevention: Institutions can stop and search people on the street"
gen st_terror3 = ((terror3-1)/3)
tab2 terror3 st_terror3


	****Construction of civil liberties (terrorism) index variable***


gen terrori=(terror1 + terror2 + terror3 )/3 
tab terrori
gen st_terrori = ((terrori-1)/3)



	****Construction of civil liberties (general) index variable***

/*Do you think that the government should or should not have the right to
monitor e-mails and any other information exchanged on the Internet?*/
recode J011_2 (-13/-12=.) (-8 -9=-99 "Missing") (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(email_mi)
recode J011_2 (-13/-8=.) (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(email)
label variable email "Government should have the right to monitor information exchanged on the internet"
gen st_email = ((email-1)/3)
tab2 email st_email


/*Do you think that the government should or should not have the right to collect information about anyone living in Germany without their knowledge*/
recode J013_1 (-13/-12=.) (-8 -9=-99 "Missing") (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(spyDE_mi)
recode J013_1 (-13/-8=.) (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(spyDE)
label variable spyDE "Government should have the right to collect information about people living in Germany"
gen st_spyDE = ((spyDE-1)/3)
tab2 spyDE st_spyDE

/*Do you think that the government should or should not have the right 
to collect information about anyone living in other countries without their knowledge*/
recode J013_2 (-13/-12=.) (-8 -9=-99 "Missing") (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(spyother_mi)
recode J013_2 (-13/-8=.) (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(spyother)
label variable spyother "Government should have the right to collect information about people living in other countries"
gen st_spyother = ((spyother-1)/3)
tab2 spyother st_spyother

/*Do you think that the government should or should not have the right to
keep people under video surveillance in public areas?*/
recode J011_1 (-13/-12=.) (-8 -9=-99 "Missing") (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(video_mi)
recode J011_1 (-13/-8=.) (1=4 "Definitely should have the right") ///
	(2=3 "Probably should have the right") (3=2 "Probably should not have the right") (4=1 "Definitely should not have the right"), gen(video)
label variable video "Government should have the right to keep people under surveillance in public areas"
gen st_video = ((video-1)/3)
tab2 video st_video


gen surveillanceindex = (video + email + spyDE + spyother)/4
tab surveillanceindex
gen st_surveillanceindex = ((surveillanceindex-1)/3)

*-------------------------------------------------------------------------------


*-------------------------------------------------------------------------------




*************************Control and Treatment Groups***************************

*Running/score variables
egen days = group (edate)
gen running1 = days - 67	/*Orlando*/
replace running1=. if running1<-30 | running1>30
gen running2 = days - 97	/*Nice*/
replace running2=. if running2<-30 | running2>30
gen running3 = days - 104	/*Munich Melee attack*/
replace running3=. if running3<-30 | running3>30
gen running4 = days - 105	/*Ansbach attack*/
replace running4=. if running3<-30 | running3>30

*Rolling variable (for the rolling window)
gen rollingw = days - 97

				

							****Groups****


/*Nice, Würzburg, Munich, Ansbach, Normandy as terror events*/

*Main definition of treatment
*20 days before Nice and 7 days after Normandy
gen treatment1 =. if respid!=.
replace treatment1 = 0 if (edate>=td(24/06/2016) & edate<=td(13/07/2016))
replace treatment1 = 1 if (edate>=td(27/07/2016) & edate<=td(02/08/2016))
label define treatment1LB 0 "Control" 1 "Treatment"
label values treatment1 treatment1LB

*30 days before Nice and 7 days after Normandy
gen treatment0 =. if respid!=.
replace treatment0 = 0 if (edate>=td(14/06/2016) & edate<=td(13/07/2016))
replace treatment0 = 1 if (edate>=td(27/07/2016) & edate<=td(02/08/2016))
label define treatment0LB 0 "Control" 1 "Treatment"
label values treatment0 treatment1LB


/*New treatment variables where only the control group is moved and the treatment
group remains the same.
First period after Brussel bombings (22.03.2019). We take 20 days wash out
period, hence the first day is 12.04.2018. As before the control is defined
as a 20 day period where no high-profile terror attask took place.*/

gen control_1 =. if respid!=.
replace control_1 = 0 if (edate>=td(12/04/2016) & edate<=td(02/05/2016))
replace control_1 = 1 if (edate>=td(27/07/2016) & edate<=td(02/08/2016))

gen control_2 =. if respid!=.
replace control_2 = 0 if (edate>=td(03/05/2016) & edate<=td(22/05/2016))
replace control_2 = 1 if (edate>=td(27/07/2016) & edate<=td(02/08/2016))

gen control_3 =. if respid!=.
replace control_3 = 0 if (edate>=td(23/05/2016) & edate<=td(11/06/2016))
replace control_3 = 1 if (edate>=td(27/07/2016) & edate<=td(02/08/2016))



*-------------------------------------------------------------------------------
						***Variables for Appendix T***
						
*Bavaria variables to indicate whether the respondent lives in Bavaria or not.
gen statedummy=.
replace statedummy=1 if land==90
replace statedummy=0 if land!=90
label define statedummyLB 0 "Not Bavaria" 1 "Bavaria"
label values statedummy statedummyLB 

*Contact attempts via phone
codebook xs08, tab(100)
recode xs08 (0=1) (1 2=2) (3 4=3) (5 6=4) (7 8=5) (9 10=6) (11 12=7) (13 14=8) (15=9), gen(phone) 
codebook phone, tab(100)
gen st_phone = (phone-1)/8 
codebook st_phone, tab(100)

*Contact attemps via house visits
codebook xs09, tab(100)
recode xs09 (1 2=1) (3 4=2) (5 6=3) (7 8=4) (9 10=5) (11 12=6) (13 14=7) ///
	(15 16=8) (17 18=9) (19 20=10) (23=11), gen(housevisits) 
codebook housevisits, tab(100)
gen st_housevisits = (housevisits-1)/10 
codebook st_housevisits, tab(100)

*Contact attemps via other means
codebook xs13, tab(100)
recode xs13 (0=1) (1 2=2) (3 4=3) (5 6=4) (7 8=5), gen(othercontacts) 
codebook othercontacts, tab(100)
gen st_othercontacts = (othercontacts-1)/4 
codebook st_othercontacts, tab(100)


*-------------------------------------------------------------------------------


*-------------------------------------------------------------------------------

save GGSS2016_analysis.dta, replace



